package com.yukefms.rule.state;

import com.yukefms.engine.running.EventCode;
import com.yukefms.engine.running.RunningContext;
import com.yukefms.engine.running.RunningEvent;
import com.yukefms.jointpoint.BodyPointCloud;
import com.yukefms.rule.interfaces.BARule;
import com.yukefms.rule.interfaces.BAStageRule;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @Description
 * @Author Ping
 * @Date 2021/6/29 10:25
 **/
public class SuccessState extends BARuleState {
    public static Logger logger = LogManager.getLogger(SuccessState.class);

    public SuccessState(final BAStageRule relatedRule) {
        super(relatedRule);
    }

    @Override
    public void doReaction(BodyPointCloud pointCloud, RunningContext context) {
       // System.out.println("success score : " + relatedRule.successScore()) ;
        context.updateScore(relatedRule.successScore());
        context.notifyRunningEventListener(EventCode.SUCCESS,
                                               relatedRule.ruleName(),
                                                             RunningEvent.EventContent.SUCCESS_CONT);
        logger.info("Congrats! the action of RULE-{} was performed successfully. ", relatedRule.ruleName()) ;
    }
    @Override
    public double getScore() {
        return this.relatedRule.successScore() ;
    }

}
